#include "Particles.h"

Particles::Particles()
{

	for (int i = 0; i < NUM_PARTICLES; i++)
	{
		mass[i] = 1.0;
		velX[i] = 0.0;
		velY[i] = 0.0;
	}

	int particle = 0;
	for (int i = 0; i < PARTICLES_X; i++)
	{
		for (int j = 0; j < PARTICLES_Y; j++)
		{
			posX[particle] = i;
			posY[particle] = j;
			particle++;
		}
	}
}

Particles::~Particles()
{
}

void Particles::nextFrame()
{
	// Do Gravity. Not in another function though, because I'm, lazy.
	for (int i = 0; i < NUM_PARTICLES; i++)
	{
		velY[i] += GRAVITY * TIME_STEP;
	}

	// This is the position altercations.
	for (int i = 0; i < NUM_PARTICLES; i++)
	{
		posX[i] += velX[i] * TIME_STEP;
		posY[i] += velY[i] * TIME_STEP;

		if (posY[i] < 0)
		{
			posY[i] = 0;
			velY[i] *= -0.8;
		}
	}
}
